package com.tjshop.android.adapter;

import com.tjshop.android.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SearchHistoryAdapter extends BaseAdapter{

	private Context mContext;
	private String[] history;
	public SearchHistoryAdapter(Context applicationContext, String[] history_arr) {
		this.mContext = applicationContext;
		this.history = history_arr;
	}

	@Override
	public int getCount() {
		return history.length;
	}

	@Override
	public Object getItem(int arg0) {
		return history[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		 ViewHolder viewHolder = null;
	        if (null == convertView)
	        {
	            viewHolder = new ViewHolder();
	            LayoutInflater mInflater = LayoutInflater.from(mContext);
	            convertView = mInflater.inflate(R.layout.search_history_item, null);

	            viewHolder.content = (TextView) convertView.findViewById(R.id.history_txt);
	            convertView.setTag(viewHolder);
	        }
	        else
	        {
	            viewHolder = (ViewHolder) convertView.getTag();
	        }

	            viewHolder.content.setText(history[arg0]);

	        return convertView;
	    }

	    private static class ViewHolder
	    {
	        TextView content;
	    }
}
